<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 200px;
            height: 200px;
            background-color: pink;
        }
    </style>
</head>
<body>
    <p>我是一段文字</p>
    <div class="box"></div>
    <script>
        const p = document.querySelector('p')
        //对象.style.样式属性 = 值
        p.style.color = 'red'
        const box = document.querySelector('.box')
        box.style.width = '300px'
        box.style.backgroundColor = 'hotpink'
    </script>
</body>
</html>